package com.yanqu.road.server.cmd.activity.douluodalu;

import com.yanqu.road.pb.activity.douluodalu.DouLuoDaLuProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.douluodalu.DouLuoDaLuMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;


//@Cmd(code = Protocol.S_DOU_LUO_DA_LU_SELECT_ENEMY_PATRONS,desc = "选择对方的的门客")
public class DouLuoDaLuSelectEnemyPatronsCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        if ((ret = DouLuoDaLuMgr.canEntryActivity(player)) != 0) return;

        if ((ret = DouLuoDaLuMgr.activityInDuiJuePeriod()) != 0) return;

        DouLuoDaLuProto.DouLuoDaLuSelectEnemyPatronsReqMsg reqMsg = DouLuoDaLuProto.DouLuoDaLuSelectEnemyPatronsReqMsg.parseFrom(packet.getBytes());
        int patronsId = reqMsg.getPatronsId();

        DouLuoDaLuProto.DouLuoDaLuSelectEnemyPatronsCrossReqMsg.Builder crossReq = DouLuoDaLuProto.DouLuoDaLuSelectEnemyPatronsCrossReqMsg.newBuilder();
        crossReq.setActivityId(DouLuoDaLuMgr.getActivityInfo().getActivityId());
        crossReq.setPatronsId(patronsId);
        //player.sendChannelPacket(Protocol.C_DOU_LUO_DA_LU_SELECT_ENEMY_PATRONS, crossReq);
    }

    @Override
    public void sendData(GamePlayer player) {
        if(ret != 0){
            player.sendPacket(Protocol.U_DOU_LUO_DA_LU_SELECT_ENEMY_PATRONS, DouLuoDaLuProto.DouLuoDaLuSelectEnemyPatronsRespMsg.newBuilder().setRet(ret));
        }
    }
}
